package com.example.tifservicedemo;

import android.content.Context;
import android.content.Intent;
import android.media.tv.TvInputService;
import android.net.Uri;
import android.util.Log;
import android.view.Surface;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

/**
 * <pre>
 * author : Nelson
 * time : 2020/12/1
 * desc:
 * </pre>
 */
public class InputService extends TvInputService {
    private static final String TAG = "InputService";

    @Override
    public void onCreate() {
        super.onCreate();
        Log.i(TAG, "onCreate: ");
    }

    @Override
    public int onStartCommand(Intent intent, int flags, int startId) {
        Log.i(TAG, "onStartCommand: ");
        return super.onStartCommand(intent, flags, startId);
    }

    @Nullable
    @Override
    public Session onCreateSession(@NonNull String inputId) {
        Log.i(TAG, "onCreateSession: ");
        return new SimpleSession(getApplication());
    }

    public class SimpleSession extends Session {

        /**
         * Creates a new Session.
         *
         * @param context The context of the application
         */
        public SimpleSession(Context context) {
            super(context);
        }

        @Override
        public void onRelease() {

        }

        @Override
        public boolean onSetSurface(@Nullable Surface surface) {
            return false;
        }

        @Override
        public void onSetStreamVolume(float volume) {

        }

        @Override
        public boolean onTune(Uri channelUri) {
            return false;
        }

        @Override
        public void onSetCaptionEnabled(boolean enabled) {

        }
    }
}
